<?php
/* @package     Joomla.Site
 * @subpackage  mod_banners
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt*/
defined('_JEXEC') or die;
require_once JPATH_ROOT . '/components/com_banners/helpers/banner.php';
$baseurl = JUri::base();
$type 		= $params->get('type',	1);
$lang = JRequest::getVar('lang','');
$Itemid = JRequest::getVar('Itemid','101');
$db = JFactory::getDBO();
if($type==0){
?>
<div class="bannergroup<?php echo $moduleclass_sfx ?>">
<?php if ($headerText) : ?>
	<?php echo $headerText; ?>
<?php endif; ?>

<?php foreach ($list as $item) : ?>
	<div class="banneritem">
		<?php $link = JRoute::_('index.php?option=com_banners&task=click&id='. $item->id);?>
		<?php if ($item->type == 1) :?>
			<?php // Text based banners ?>
			<?php echo str_replace(array('{CLICKURL}', '{NAME}'), array($link, $item->name), $item->custombannercode);?>
		<?php else:?>
			<?php $imageurl = $item->params->get('imageurl');?>
			<?php $width = $item->params->get('width');?>
			<?php $height = $item->params->get('height');?>
			<?php if (BannerHelper::isImage($imageurl)) :?>
				<?php // Image based banner ?>
				<?php $alt = $item->params->get('alt');?>
				<?php $alt = $alt ? $alt : $item->name; ?>
				<?php $alt = $alt ? $alt : JText::_('MOD_BANNERS_BANNER'); ?>
				<?php if ($item->clickurl) :?>
					<?php // Wrap the banner in a link?>
					<?php $target = $params->get('target', 1);?>
					<?php if ($target == 1) :?>
						<?php // Open in a new window?>
						<a
							href="<?php echo $link; ?>" target="_blank"
							title="<?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8');?>">
							<img
								src="<?php echo $baseurl . $imageurl;?>"
								alt="<?php echo $alt;?>"
								<?php if (!empty($width)) echo 'width ="'. $width.'"';?>
								<?php if (!empty($height)) echo 'height ="'. $height.'"';?>
							/>
						</a>
					<?php elseif ($target == 2):?>
						<?php // open in a popup window?>
						<a
							href="<?php echo $link;?>" onclick="window.open(this.href, '',
								'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550');
								return false"
							title="<?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8');?>">
							<img
								src="<?php echo $baseurl . $imageurl;?>"
								alt="<?php echo $alt;?>"
								<?php if (!empty($width)) echo 'width ="'. $width.'"';?>
								<?php if (!empty($height)) echo 'height ="'. $height.'"';?>
							/>
						</a>
					<?php else :?>
						<?php // open in parent window?>
						<a
							href="<?php echo $link;?>"
							title="<?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8');?>">
							<img
								src="<?php echo $baseurl . $imageurl;?>"
								alt="<?php echo $alt;?>"
								<?php if (!empty($width)) echo 'width ="' . $width . '"';?>
								<?php if (!empty($height)) echo 'height ="' . $height . '"';?>
							/>
						</a>
					<?php endif;?>
				<?php else :?>
					<?php // Just display the image if no link specified?>
					<img
						src="<?php echo $baseurl . $imageurl;?>"
						alt="<?php echo $alt;?>"
						<?php if (!empty($width)) echo 'width ="' . $width . '"';?>
						<?php if (!empty($height)) echo 'height ="' . $height . '"';?>
					/>
				<?php endif;?>
			<?php elseif (BannerHelper::isFlash($imageurl)) :?>
				<object
					classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
					codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
					<?php if (!empty($width)) echo 'width ="'. $width.'"';?>
					<?php if (!empty($height)) echo 'height ="'. $height.'"';?>
				>
					<param name="movie" value="<?php echo $imageurl;?>" />
					<embed
						src="<?php echo $imageurl;?>"
						loop="false"
						pluginspage="http://www.macromedia.com/go/get/flashplayer"
						type="application/x-shockwave-flash"
						<?php if (!empty($width)) echo 'width ="'. $width.'"';?>
						<?php if (!empty($height)) echo 'height ="'. $height.'"';?>
					/>
				</object>
			<?php endif;?>
		<?php endif;?>
		<div class="clr"></div>
	</div>
<?php endforeach; ?>

<?php if ($footerText) : ?>
	<div class="bannerfooter">
		<?php echo $footerText; ?>
	</div>
<?php endif; ?>
</div>
<?php
}
else if($type==1){
?>
<section id="<?php echo $moduleclass_sfx ?>" style="overflow: hidden;width: 100%;">
    <div class="cromaslideinner" style="width:100%;height:auto;position:relative;">
         <script type="text/javascript">var lsjQuery = jQuery;</script>
         <script type="text/javascript">
             lsjQuery(document).ready(function(){ 
                 if(typeof lsjQuery.fn.layerSlider=="undefined"){lsShowNotice('layerslider_1','jquery');} 
                 else{lsjQuery("#layerslider_1").layerSlider({
                     responsiveUnder:1100, 
                     pauseOnHover:false, 
                     twoWaySlideshow:true, 
                     skin:'fullwidth', 
                     hoverPrevNext:false, 
                     navStartStop:false, 
                     navButtons:false, 
                     showCircleTimer:false, 
                     yourLogoStyle:'left: 10px; top: 10px;', 
                     cbInit:function(element){ }, 
                     cbStart:function(data){ }, 
                     cbStop:function(data){ }, 
                     cbPause:function(data){ }, 
                     cbAnimStart:function(data){ }, 
                     cbAnimStop:function(data){ }, 
                     cbPrev:function(data){ }, 
                     cbNext:function(data){ }, 
                     skinsPath:''
                    }) 
                } 
             }); 
         </script>
         <div id="layerslider_1" class="ls-wp-container ls-container ls-fullwidth" style="max-width: 100%; margin: 0px auto; visibility: visible; width: 100%; height: 650px;">
             <div style="" class="ls-inner">
                 <div style="display: block;" class="ls-lt-container ls-overflow-hidden">
                     <div style="overflow: hidden;" class="ls-curtiles">
                         <div style="overflow: hidden;" class="ls-lt-tile">
                             <div class="ls-curtile">
                                <?php 
                                    $urlimg=$list[0]->params;
                                    $urlimg=explode('imageurl":"',$urlimg);
                                    $urlimg=explode('","',$urlimg[1]);
                                    $urlimg=str_replace('\/','/',$urlimg[0]);
                                ?>
                                <img style="" src="<?php echo $baseurl.$urlimg;?>">
                             </div>
                         </div>
                     </div>
                 </div>
                 <?php 
                 $i=0;
                 foreach ($list as $item) : 
                     //$link = JRoute::_('index.php?option=com_banners&task=click&id='. $item->id);
                     $imageurl = $item->params->get('imageurl');
                 ?>
                     <div style="display: none; visibility: visible; left: auto; right: 0px; top: 0px; bottom: auto;" class="ls-slide <?php if($i==0){echo 'ls-active';}?>" data-ls="slidedelay:9000;transition2d:5;">
                         <img src="<?php echo $baseurl.$imageurl;?>" data-src="<?php echo $baseurl.$imageurl;?>" class="ls-bg ls-preloaded">
                         <div style="width:auto;height:auto;padding:0px;border-width:0px;left:0px;top:0px;" class="ls-gpuhack"></div>
                         <h1 class="ls-l cro_cust_font" style="font-size:30px;line-height:30px;top:250px;letter-spacing:5px;font-weight:300;" data-ls="offsetxin:right;durationin:750;easingin:easeInOutBack;"><?php echo htmlspecialchars($item->name, ENT_QUOTES, 'UTF-8');?></h1>
                         <h1 class="ls-l cro_cust_font" style="font-size:79px;line-height:79px;top:280px;letter-spacing:15px;font-weight:300;" data-ls="offsetxin:left;durationin:750;easingin:easeInOutBack;"><?php echo htmlspecialchars($item->description, ENT_QUOTES, 'UTF-8');?></h1>
                     </div>
                 <?php
                 $i++;
                 endforeach; 
                 ?>
             </div>
             <div class="ls-loading-container" style="z-index: -1; display: none;">
                <div class="ls-loading-indicator"></div>
             </div>
             <a style="visibility: visible;" class="ls-nav-prev" href="#"></a>
             <a style="visibility: visible;" class="ls-nav-next" href="#"></a>
             <div class="ls-shadow"></div>
         </div>	
    </div>
</section>
<?php
}
else if($type==2){
	
}
?>